package com.neuedu.web.controller.yunong;

import java.util.List;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.neuedu.common.annotation.Log;
import com.neuedu.common.core.controller.BaseController;
import com.neuedu.common.core.domain.AjaxResult;
import com.neuedu.common.enums.BusinessType;
import com.neuedu.yunong.domain.Talentflow;
import com.neuedu.yunong.service.ITalentflowService;
import com.neuedu.common.utils.poi.ExcelUtil;
import com.neuedu.common.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 人才流动Controller
 *
 * @author zl
 * @date 2024-12-10
 */
@RestController
@RequestMapping("/personnel/talentflow")
@Tag(name = "【人才流动】管理")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class TalentflowController extends BaseController
{
    private final ITalentflowService talentflowService;

    /**
     * 查询人才流动列表
     */
    @Operation(summary = "查询人才流动列表")
    @PreAuthorize("@ss.hasPermi('personnel:talentflow:list')")
    @GetMapping("/list")
    public TableDataInfo list(Talentflow talentflow)
    {
        startPage();
        List<Talentflow> list = talentflowService.selectTalentflowList(talentflow);
        return getDataTable(list);
    }

    /**
     * 导出人才流动列表
     */
    @Operation(summary = "导出人才流动列表")
    @PreAuthorize("@ss.hasPermi('personnel:talentflow:export')")
    @Log(title = "人才流动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Talentflow talentflow)
    {
        List<Talentflow> list = talentflowService.selectTalentflowList(talentflow);
        ExcelUtil<Talentflow> util = new ExcelUtil<Talentflow>(Talentflow.class);
        util.exportExcel(response, list, "人才流动数据");
    }

    /**
     * 获取人才流动详细信息
     */
    @Operation(summary = "获取人才流动详细信息")
    @PreAuthorize("@ss.hasPermi('personnel:talentflow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(talentflowService.selectTalentflowById(id));
    }

    /**
     * 新增人才流动
     */
    @Operation(summary = "新增人才流动")
    @PreAuthorize("@ss.hasPermi('personnel:talentflow:add')")
    @Log(title = "人才流动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Talentflow talentflow)
    {
        return toAjax(talentflowService.insertTalentflow(talentflow));
    }

    /**
     * 修改人才流动
     */
    @Operation(summary = "修改人才流动")
    @PreAuthorize("@ss.hasPermi('personnel:talentflow:edit')")
    @Log(title = "人才流动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Talentflow talentflow)
    {
        return toAjax(talentflowService.updateTalentflow(talentflow));
    }

    /**
     * 删除人才流动
     */
    @Operation(summary = "删除人才流动")
    @PreAuthorize("@ss.hasPermi('personnel:talentflow:remove')")
    @Log(title = "人才流动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable( name = "ids" ) Long[] ids)
    {
        return toAjax(talentflowService.deleteTalentflowByIds(ids));
    }
}
